package com.xyht.sca_s.student_manage_system.modules.rxRegistration.controller;


import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.rxRegistration.entity.req.RxRegistrationChargeCategoryReq;
import com.xyht.sca_s.student_manage_system.modules.rxRegistration.service.RxRegistrationChargeCategoryDetailService;
import com.xyht.sca_s.student_manage_system.modules.rxRegistration.service.RxRegistrationChargeCategoryService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 * 收费项主项 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2024-05-07
 */
@RestController
@RequestMapping("/rxRegistration/chargeCategory")
@SecretBody
public class RxRegistrationChargeCategoryController {
    @Resource
    private RxRegistrationChargeCategoryService rxRegistrationChargeCategoryService;

    @PostMapping("/add")
    @ApiModelProperty("添加收费项")
    public ResponseResult addRxRegistrationChargeCategory(@RequestBody RxRegistrationChargeCategoryReq chargeCategoryReq){
        return rxRegistrationChargeCategoryService.addRxRegistrationChargeCategory(chargeCategoryReq);
    }
    @PostMapping("/update")
    @ApiModelProperty("修改收费项")
    public ResponseResult updateRxRegistrationChargeCategory(@RequestBody RxRegistrationChargeCategoryReq chargeCategoryReq){
        return rxRegistrationChargeCategoryService.updateRxRegistrationChargeCategory(chargeCategoryReq);
    }
    @PostMapping("/delete")
    @ApiModelProperty("删除收费项")
    public ResponseResult deleteRxRegistrationChargeCategory(@RequestBody RxRegistrationChargeCategoryReq chargeCategoryReq){
        return rxRegistrationChargeCategoryService.deleteRxRegistrationChargeCategory(chargeCategoryReq);
    }
    @GetMapping("/list")
    @ApiModelProperty("获取收费项列表(只能修改名字，价格)")
    public ResponseResult getRxRegistrationChargeCategoryList(@RequestParam(value = "searchStr", required = false) String searchStr,
                                                              @RequestParam(value = "type", required = false) Integer type,
                                                              @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
                                                              @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum){
        return rxRegistrationChargeCategoryService.getRxRegistrationChargeCategoryList(searchStr, type, pageNum, pageSize);
    }

    @GetMapping("/check")
    @ApiModelProperty("修改收费项之前，检查收费项是否在收费计划中")
    public ResponseResult checkRxRegistrationChargeCategoryIsPlan(@RequestParam(value = "chargeCategoryId") String chargeCategoryId){
        return rxRegistrationChargeCategoryService.checkRxRegistrationChargeCategoryIsPlan(chargeCategoryId);
    }

}

